﻿using Admin.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace Admin.DAL
{
    public class ConnectionDB:DbContext
    {
        public DbSet<ProductModel> promodel { set; get; }
        public String connectString = "Server=.;Database=LazadaDB;User Id=sa;Password=sa;";
        SqlConnection con;

        public ConnectionDB()
        {
            con = new SqlConnection(connectString);
            con.Open();
        }
        public SqlConnection Connection
        {
            get
            {
                if (con.State == ConnectionState.Closed)
                    con.Open();
                return con;
            }
        }
        
        

        public SqlCommand CreateCommand(string sql)
        {
            SqlCommand cmd = new SqlCommand(sql, Connection);
            return cmd;
        }
    }
}